package sorted;

public class sorted_01 {
    public static void main(String[] args) {
        int[] arr = {24, 7, 43, 78, 62, 98, 82, 18, 54, 37, 73, 9};
        int[] ints = sorted(arr);
        for (int i = 0; i < ints.length; i++) {
            System.out.print(ints[i] + " ");
        }
    }

    /**
     * 冒泡排序
     *
     * @param array
     * @return
     */
    public static int[] sorted(int[] array) {
        //如果数组长度为0，无需排序
        if (array.length == 0) {
            return array;
        }
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array.length - i - 1; j++) {
                if (array[j + 1] > array[j]) {
                    int temp = array[j + 1];
                    array[j + 1] = array[j];
                    array[j] = temp;
                }
            }
        }
        return array;
    }
}
